﻿@model ESN.Models.Results
@{
    ViewBag.Title = "ViewResult";
}
        <script src="/Scripts/jquery-1.7.1.min.js" type="text/javascript"></script>
        <script src="/Scripts/jquery-ui-1.8.16.js"" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function () {

    });
</script>
<h2>@ESN.Languages.LangString.Load("by", "Quiz") <a href="/@ViewBag.UserName/Home">@ViewBag.DisplayName</a> @ESN.Languages.LangString.Load("at", "Quiz") <span>@ViewBag.At</span></h2>
<h3>@ESN.Languages.LangString.Load("in", "Quiz") <span>@ViewBag.Take</span></h3>
<h3><b>@ViewBag.PointLabel</b>:@ViewBag.Point</h3>
<div>
@for (int i = 0; i < Model.questions.Count(); i++)
{
    <div class="ui-corner-all ui-widget-content" style="margin-bottom:5px;">
        <h3>@ESN.Languages.LangString.Load("question", "Quiz") : @Model.questions[i].ques <span>(<b>@ViewBag.PointLabel</b>: @Model.questions[i].point)</span></h3>
        <hr />
        <div>
        @if (Model.questions[i].type == 0 || Model.questions[i].type == 1)
        {
            var ans = Model.answers[i].ToArray();
            var corr = Model.corrects[i].ToArray();
            <table>
                <tr>
                    <th></th>
                    <th>@ViewBag.Corr</th>
                </tr>
            @for (int j = 0; j < Model.questions[i].numAns; j++)
            {
                <tr>
                @if (Array.IndexOf(ans, j.ToString()) > -1)
                {
                    <td><b style="margin-left:5px;">@Model.questions[i].ans[j]</b></td>
                }
                else
                {
                    <td><span>@Model.questions[i].ans[j]</span></td>
                }
                @if (Array.IndexOf(corr, j.ToString()) > -1)
                {
                    <td><b>&#10003;</b></td>
                }
                </tr>
            }
            </table>
        }
        else if (Model.questions[i].type == 2)
        {
            <table>
                <tr>
                    <th></th>
                    <th>@ViewBag.Ans</th>
                    <th>@ViewBag.Corr</th>
                </tr> 
            @for (int j = 0; j < Model.questions[i].numAns; j++)
            {
                <tr>
                    <td>
                        @Model.questions[i].ansA[j]
                    </td>
                    <td>
                        @Model.questions[i].ansB[Int16.Parse(Model.answers[i][j])]
                    </td>
                    <td>
                        @Model.questions[i].ansB[Int16.Parse(Model.corrects[i][j])]
                    </td>
                </tr>
            }
            </table>
        }
        else if (Model.questions[i].type == 3)
        {
            <table>
                <tr>
                    <th>@ViewBag.Ans</th>
                    <th>@ViewBag.Corr</th>
                </tr> 
            @for (int j = 0; j < Model.questions[i].numAns; j++)
            {
                <tr>
                    <td>
                        @Model.answers[i][j]
                    </td>
                    <td>
                        @Model.corrects[i][j]
                    </td>
                </tr>
            }
            </table>
        }
        else
        {
            <div>@Model.answers[i][0]</div>
        }
        </div>
    </div>
}
</div>
